package com.cisetech.web.bobocai.qiantai;


import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.cisetech.mapper.bobocai.TitleMapper;
import com.cisetech.service.CodeService;
import com.cisetech.service.ColumnService;
import com.cisetech.service.IndexService;
import com.cisetech.vo.bobocai.CodeVo;
import com.cisetech.vo.bobocai.LContent;
import com.cisetech.vo.bobocai.QianTaiVo;
import com.cisetech.vo.bobocai.TitleVo;
/**
 * 首页控制器
 * @author Administrator
 *
 */
@Controller
public class IndexReceptionController {
	@Autowired
	IndexService indexService;
	@Autowired
	TitleMapper titleMapper;
	@Autowired
	CodeService codeService;
	@Autowired
	ColumnService columnService;
	
	@RequestMapping(value="index",method=RequestMethod.GET)
	public String index(Model model,HttpServletRequest request,HttpServletResponse response){
		//首页title等信息展示
		TitleVo titleVo = new TitleVo();
		//设置获取网站首页的title信息
		titleVo.setPrId("0");
		List<TitleVo> list = titleMapper.findTitleHeadByPrId(titleVo);
		if(list!=null && list.size()>0){
			model.addAttribute("titleVo", list.get(0));
		}else{
			model.addAttribute("titleVo", new TitleVo());
		}
		
		List<LContent> newList = indexService.getListContent("0");//新发布的展会
		model.addAttribute("newList", newList);			
		List<LContent> newDateList = indexService.getListContent("1");//即将展开的展会
		model.addAttribute("newDateList", newDateList);
		List<LContent> imgList = indexService.getListContent("2");//轮播图推荐的展会
		model.addAttribute("imgList", imgList);
		if("e".equals(request.getParameter("e"))){
			return "qiantai/e/index";
		}
		return "qiantai/index";
	}
	//获取行业
	@ResponseBody
	@RequestMapping(value="/index/getCode",method=RequestMethod.POST)
	public List<CodeVo> getCode(HttpServletRequest request,HttpServletResponse response){
		CodeVo codeVo = new CodeVo();
		codeVo.setProductType("1");
		List<CodeVo> list = codeService.getlistss(codeVo);
		return list;
	}
	//获取地区
	@ResponseBody
	@RequestMapping(value="/region/getlist",method=RequestMethod.POST)
	public List<QianTaiVo> getRegionList(QianTaiVo qianTaiVo,HttpServletRequest request,HttpServletResponse reponse){
		List<QianTaiVo> list = new ArrayList<QianTaiVo>();
		if("请选择".equals(qianTaiVo.getcState())){
			qianTaiVo.setcState("");
		}
		if("请选择".equals(qianTaiVo.getcCountry())){
			qianTaiVo.setcCountry("");
		}
		list = columnService.getRegionList(qianTaiVo);
		return list;
	}
	
}
